﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using System.Threading;
using System.Windows.Forms;
 
using Tao;
using Tao.OpenGl;
using Tao.Platform;

namespace VoltGameEditor
{
    public partial class ValueEditor : Form
    {
        public TextBox tb_value;
        public Label lbl_desc;

        public ValueEditor()
        {
            InitializeComponent();
        }

        public String ShowValEditor(string labelText)
        {
            this.Location = new Point(MainWin.MousePosition.X + 10, MainWin.MousePosition.Y + 10);
            this.KeyDown += new KeyEventHandler(ValEditor_KeyDown);
            this.Load += new EventHandler(ValEditor_Load);

            lbl_desc.Size = new Size((int)(labelText.Length * 8.5), this.Size.Height);
            lbl_desc.Text = labelText;

            this.ShowDialog();

            if ((bool)tb_value.Tag == true)
                return tb_value.Text;
            else
                return null;
        }

        public void ValEditor_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                tb_value.Tag = true;
                this.Close();
            }
            else if (e.KeyCode == Keys.Escape)
            {
                tb_value.Tag = false;
                this.Close();
            }
        }
        public void ValEditor_Load(object sender, EventArgs e)
        {
            Program.ValEditor.Size = new Size(150, 17);
        }

        private void InitializeComponent() //Auto-Generated Code :: DO NOT MODIFY
        {
			this.lbl_desc = new System.Windows.Forms.Label();
			this.tb_value = new System.Windows.Forms.TextBox();
			this.SuspendLayout();
			// 
			// lbl_desc
			// 
			this.lbl_desc.BackColor = System.Drawing.Color.Transparent;
			this.lbl_desc.Dock = System.Windows.Forms.DockStyle.Left;
			this.lbl_desc.Location = new System.Drawing.Point(0, 0);
			this.lbl_desc.Margin = new System.Windows.Forms.Padding(1);
			this.lbl_desc.Name = "lbl_desc";
			this.lbl_desc.Padding = new System.Windows.Forms.Padding(1);
			this.lbl_desc.Size = new System.Drawing.Size(80, 39);
			this.lbl_desc.TabIndex = 0;
			this.lbl_desc.Text = "=[ text ]=";
			this.lbl_desc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// tb_value
			// 
			this.tb_value.BackColor = System.Drawing.Color.LightGoldenrodYellow;
			this.tb_value.BorderStyle = System.Windows.Forms.BorderStyle.None;
			this.tb_value.Dock = System.Windows.Forms.DockStyle.Fill;
			this.tb_value.Location = new System.Drawing.Point(80, 0);
			this.tb_value.MaxLength = 64;
			this.tb_value.Name = "tb_value";
			this.tb_value.Size = new System.Drawing.Size(312, 13);
			this.tb_value.TabIndex = 1;
			// 
			// ValueEditor
			// 
			this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
			this.BackColor = System.Drawing.Color.LightGoldenrodYellow;
			this.ClientSize = new System.Drawing.Size(392, 39);
			this.ControlBox = false;
			this.Controls.Add(this.tb_value);
			this.Controls.Add(this.lbl_desc);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
			this.KeyPreview = true;
			this.Name = "ValueEditor";
			this.Opacity = 0.95D;
			this.ShowIcon = false;
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
			this.Text = "nothing";
			this.TopMost = true;
			this.ResumeLayout(false);
			this.PerformLayout();

        }
    }
}
